<?php
namespace Admin\Controller;
use Think\Controller;
class CommonController extends Controller {
	public function _initialize(){
                         if (! isset($_SESSION['ADMINID'])  ||  $_SESSION['ADMINID'] =='') {
                                     $this->redirect('Admin/Login/login','', 1,'未登录，1秒后跳转至登录界面');
                         }
                         $Message = M("Message");
                         $msgnumber = $Message->count();
                         $msglist=$Message->select();
                         $msglistdata = array();
                         foreach ($msglist as $value) {
                         		if ($value['action'] == "提醒发货") {
                         			$value['cnt'] = "订单编号为".$value['orderid']."的买家提醒发货"; 
                         		}
                         		if ($value['action'] == "确认收货") {
                         			$value['cnt'] = "订单编号为".$value['orderid']."的买家确认收货"; 
                         		}
                         		$d = time()-$value['sendtime'];
                         		if($d<60){ 
			             $value['time'] = $d.'秒前'; 
			 }else{ 
			             if($d<3600){ 
			                	$value['time'] = floor($d/60).'分钟前'; 
			             }else{ 
				             if($d<86400){ 
				                    	$value['time'] = floor($d/3600).'小时前'; 
			              	 }else{ 
				                    	if($d<259200){//3天内 
				                        		$value['time'] = floor($d/86400).'天前'; 
					             }else{ 
					                         $value['time'] = date('Y-m-d H:i:s',$value['sendtime']); 
					             } 
			                	} 
			            } 
			} 
                         		$msglistdata[ ] =$value;
                         }
                         $this->assign("msglistdata",$msglistdata);
                         $this->assign("msgnumber",$msgnumber);
             }
             

}